package com.magic.smartcity.view.more.adapters

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.magic.smartcity.R
import com.magic.smartcity.beans.ActivityRotation
import com.magic.smartcity.databinding.ItemActivityTocationImageBinding
import com.magic.smartcity.utils.Constant
import com.youth.banner.adapter.BannerAdapter

/**
 * @description:
 * @create: Create by Magic on 2022/2/15.
 */
class ActivityHomeBannerAdapter(data: List<ActivityRotation>) :
    BannerAdapter<ActivityRotation, ActivityHomeBannerAdapter.ItemHolder>(data) {

    private val TAG: String = "ActivityHomeBannerAdapter"

    class ItemHolder(binding: ItemActivityTocationImageBinding) :
        RecyclerView.ViewHolder(binding.root) {
        var binding = binding
    }

    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): ItemHolder {
        val binding = DataBindingUtil.inflate<ItemActivityTocationImageBinding>(
            LayoutInflater.from(parent?.context),
            R.layout.item_activity_tocation_image,
            parent,
            false
        )
        return ItemHolder(binding)
    }

    override fun onBindView(
        holder: ItemHolder?,
        data: ActivityRotation?,
        position: Int,
        size: Int
    ) {
        Glide.with(holder?.binding?.root!!).load(Constant.Service_IP+data?.advImg).into(holder.binding.image)
    }
}